﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SBlogCore.Common.DatabaseAccessor.Attributes;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace SBlogCore.Common.DatabaseAccessor.Entitys
{
    /// <summary>
    /// 基础实体
    /// </summary>
    [SkipScan]
    public abstract class BaseEntity : IBaseEntity
    {
        /// <summary>
        /// 主键Id
        /// </summary>
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        [Dapper.Contrib.Extensions.ExplicitKey]
        [Comment("主键ID")]
        public virtual long Id { get; set; }

        /// <summary>
        /// 组织ID
        /// </summary>
        [Comment("组织ID")]
        public virtual long? SysOrgId { get; set; }

        /// <summary>
        /// 子公司ID
        /// </summary>
        [Comment("子公司ID")]
        public virtual long? PlantId { get; set; }

        /// <summary>
        /// 老系统ID
        /// </summary>
        [Comment("老系统ID")]
        public string? OldId { get; set; }

        /// <summary>
        /// 租户Id
        /// </summary>
        [Comment("租户Id")]
        public virtual Guid? TenantId { get; set; }
    }
    /// <summary>
    /// 创建基础实体
    /// </summary>
    public abstract class CreateEntity : BaseEntity
    {
        /// <summary>
        /// 创建时间
        /// </summary>
        [Comment("创建时间")]
        public virtual DateTimeOffset? CreatedTime { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        [Comment("更新时间")]
        public virtual DateTimeOffset? UpdatedTime { get; set; }

        /// <summary>
        /// 创建者Id
        /// </summary>
        [Comment("创建者Id")]
        public virtual long? CreatedUserId { get; set; }

        /// <summary>
        /// 修改者Id
        /// </summary>
        [Comment("修改者Id")]
        public virtual long? UpdatedUserId { get; set; }
    }
    /// <summary>
    /// 假删除基础实体
    /// </summary>
    public abstract class DeleteEntity : CreateEntity
    {
        /// <summary>
        /// 软删除
        /// </summary>
        [Comment("软删除")]
        public virtual bool IsDeleted { get; set; }
    }
}
